package cn.com.lms.business.examRewrite.web;

import cn.com.lms.business.exam.persistence.entity.QuestionCategory;
import cn.com.lms.business.examRewrite.persistence.entity.QuestionCategoryReWrite;
import cn.com.lms.business.examRewrite.service.QuestionCategoryReWriteService;
import com.bnzj.core.rest.ResponseResult;
import io.lettuce.core.GeoArgs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/exam/question/category")
public class QuestionCategoryReWriteController {

    @Autowired
    QuestionCategoryReWriteService questionCategoryReWriteService;

    /**
     * 获取树形结构
     * @return
     */
    @GetMapping("/getTreeReWrite")
    public ResponseResult<?> getTree(){
        QuestionCategoryReWrite root = QuestionCategoryReWrite.getRoot();
        List<QuestionCategoryReWrite> list = questionCategoryReWriteService.getMenuTree();
        root.setChildren(list);
        List<QuestionCategoryReWrite> rootList= Arrays.asList(root);
        return ResponseResult.success(rootList);
    }


}
